﻿@{
    ViewBag.Title = "Article";
    Layout = "~/Views/Shared/BE/_Admin_Layout.cshtml";
}
<article class="module width_3_quarter">
<div id="ArticleTable"></div>
</article>

<script type="text/javascript">

    $(document).ready(function () {

        //Prepare jtable plugin
        $('#ArticleTable').jtable({
            selecting: true, //Enable selecting
            multiselect: true, //Allow multiple selecting
            selectingCheckboxes: true, //Show checkboxes on first column
            openChildAsAccordion: true,
            sorting: true,
            paging: true,
            pageSize: 10,
            columnResizable: false,
            defaultSorting: 'CreatedTime DESC',
            title: 'Danh sách các bài viết',
            actions: {
                listAction: '@Url.Action("ListArticle","ArticleManagement")',
                deleteAction: '@Url.Action("DeleteArticle","ArticleManagement")',
                //updateAction: '/ArticleManagement/UpdateArticle',
                //createAction: '/ArticleManagement/CreateArticle'
            },
            fields: {
                ArticleID: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false
                },
                ArticleTitle: {
                    title: 'Tiêu đề',
                    width: '45%'
                },
                CategoryName:
                    {
                        title: 'Chuyên mục',
                        width: '25%'
                    },
                CreatedTime: {
                    title: 'Ngày gửi',
                    type: 'date',
                    displayFormat: 'dd-mm-yy'
                }
            }
        });

        //Re-load records when user click 'load records' button.
        $('#LoadRecordsButton').click(function (e) {
            e.preventDefault();
            $('#ArticleTable').jtable('load', {
                keywords: $('#name').val(),
            });
        });
        //
        //Delete selected students
        $('#DeleteAllButton').button().click(function () {
            var $selectedRows = $('#ArticleTable').jtable('selectedRows');
            $('#ArticleTable').jtable('deleteRows', $selectedRows);
        });
        
        //Load person list from server
        $('#ArticleTable').jtable('load');
    });
</script>
<script type="text/javascript">
    $(document).ready(function () {
        var newbt = $('#ArticleTable #DeleteAllButton');
        $('#ArticleTable .head_table').append(newbt);
    });
</script>